




/*
'===============================================================================
'  HNG.Portal.BL.TblSanPhamManagerBase
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using HNG.Portal.BLL;
using HNG.Portal.DAL;
using HNG.Portal.DAL.EntityClasses;
using HNG.Portal.DAL.FactoryClasses;
using HNG.Portal.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
using System.Windows.Forms;
namespace HNG.Portal.BLL
{
	public class TblSanPhamManagerBase
	{
	    
		#region ColumnNames
		
				public const String Field_Id="Id";
				
				public const String Field_Barcode="Barcode";
				
				public const String Field_DanhMucSpid="DanhMucSpid";
				
				public const String Field_TenDanhMuc="TenDanhMuc";
				
				public const String Field_TenSanPham="TenSanPham";
				
				public const String Field_TomTatHome="TomTatHome";
				
				public const String Field_TomTat="TomTat";
				
				public const String Field_Mota="Mota";
				
				public const String Field_NhaCcid="NhaCcid";
				
				public const String Field_MaTienTe="MaTienTe";
				
				public const String Field_Image="Image";
				
				public const String Field_KhuyenMaiText="KhuyenMaiText";
				
				public const String Field_GiaBan="GiaBan";
				
				public const String Field_GiaCu="GiaCu";
				
				public const String Field_ThoiGianBaoHanh="ThoiGianBaoHanh";
				
				public const String Field_DonViBaoHanh="DonViBaoHanh";
				
				public const String Field_MetaKeyword="MetaKeyword";
				
				public const String Field_MetaDesc="MetaDesc";
				
				public const String Field_Tongquan="Tongquan";
				
				public const String Field_Tinhnang="Tinhnang";
				
				public const String Field_Baogom="Baogom";
				
				public const String Field_Hinhthuc="Hinhthuc";
				
				public const String Field_Baohanh="Baohanh";
				
				public const String Field_Count="Count";
				
				public const String Field_SoLuong="SoLuong";
				
				public const String Field_ThuTu="ThuTu";
				
				public const String Field_ChkQuantity="ChkQuantity";
				
				public const String Field_TxtQuantity="TxtQuantity";
				
				public const String Field_DonViTinhId="DonViTinhId";
				
				public const String Field_Spmoi="Spmoi";
				
				public const String Field_SpnoiBat="SpnoiBat";
				
				public const String Field_SpHot="SpHot";
				
				public const String Field_NgayDang="NgayDang";
				
				public const String Field_TrangThai="TrangThai";
				
		#endregion	
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		public TblSanPhamManagerBase()
		{
			// Nothing for now.
		}
		public DataTable Clone()
		{
			DataTable dt = new DataTable();
						
			
			dt.Columns.Add(Field_Id,typeof(int));
			
						
			
			dt.Columns.Add(Field_Barcode,typeof(string));
			
						
			
			dt.Columns.Add(Field_DanhMucSpid,typeof(int));
			
						
			
			dt.Columns.Add(Field_TenDanhMuc,typeof(string));
			
						
			
			dt.Columns.Add(Field_TenSanPham,typeof(string));
			
						
			
			dt.Columns.Add(Field_TomTatHome,typeof(string));
			
						
			
			dt.Columns.Add(Field_TomTat,typeof(string));
			
						
			
			dt.Columns.Add(Field_Mota,typeof(string));
			
						
			
			dt.Columns.Add(Field_NhaCcid,typeof(string));
			
						
			
			dt.Columns.Add(Field_MaTienTe,typeof(string));
			
						
			
			dt.Columns.Add(Field_Image,typeof(string));
			
						
			
			dt.Columns.Add(Field_KhuyenMaiText,typeof(string));
			
						
			
			dt.Columns.Add(Field_GiaBan,typeof(double));
			
						
			
			dt.Columns.Add(Field_GiaCu,typeof(double));
			
						
			
			dt.Columns.Add(Field_ThoiGianBaoHanh,typeof(int));
			
						
			
			dt.Columns.Add(Field_DonViBaoHanh,typeof(string));
			
						
			
			dt.Columns.Add(Field_MetaKeyword,typeof(string));
			
						
			
			dt.Columns.Add(Field_MetaDesc,typeof(string));
			
						
			
			dt.Columns.Add(Field_Tongquan,typeof(string));
			
						
			
			dt.Columns.Add(Field_Tinhnang,typeof(string));
			
						
			
			dt.Columns.Add(Field_Baogom,typeof(string));
			
						
			
			dt.Columns.Add(Field_Hinhthuc,typeof(string));
			
						
			
			dt.Columns.Add(Field_Baohanh,typeof(string));
			
						
			
			dt.Columns.Add(Field_Count,typeof(int));
			
						
			
			dt.Columns.Add(Field_SoLuong,typeof(double));
			
						
			
			dt.Columns.Add(Field_ThuTu,typeof(int));
			
						
			
			dt.Columns.Add(Field_ChkQuantity,typeof(int));
			
						
			
			dt.Columns.Add(Field_TxtQuantity,typeof(string));
			
						
			
			dt.Columns.Add(Field_DonViTinhId,typeof(int));
			
						
			
			dt.Columns.Add(Field_Spmoi,typeof(bool));
			
						
			
			dt.Columns.Add(Field_SpnoiBat,typeof(bool));
			
						
			
			dt.Columns.Add(Field_SpHot,typeof(bool));
			
						
			
			dt.Columns.Add(Field_NgayDang,typeof(DateTime));
			
						
			
			dt.Columns.Add(Field_TrangThai,typeof(bool));
			
			            
            return dt;			
		}
			
		public TblSanPhamEntity Convert_Entity(TblSanPhamEntity _TblSanPhamEntity,TblSanPhamEntity _TblSanPhamEntity_XML)
		{	
			
				
			_TblSanPhamEntity.Id= _TblSanPhamEntity_XML.Id;
				
			_TblSanPhamEntity.Barcode= _TblSanPhamEntity_XML.Barcode;
				
			_TblSanPhamEntity.DanhMucSpid= _TblSanPhamEntity_XML.DanhMucSpid;
				
			_TblSanPhamEntity.TenDanhMuc= _TblSanPhamEntity_XML.TenDanhMuc;
				
			_TblSanPhamEntity.TenSanPham= _TblSanPhamEntity_XML.TenSanPham;
				
			_TblSanPhamEntity.TomTatHome= _TblSanPhamEntity_XML.TomTatHome;
				
			_TblSanPhamEntity.TomTat= _TblSanPhamEntity_XML.TomTat;
				
			_TblSanPhamEntity.Mota= _TblSanPhamEntity_XML.Mota;
				
			_TblSanPhamEntity.NhaCcid= _TblSanPhamEntity_XML.NhaCcid;
				
			_TblSanPhamEntity.MaTienTe= _TblSanPhamEntity_XML.MaTienTe;
				
			_TblSanPhamEntity.Image= _TblSanPhamEntity_XML.Image;
				
			_TblSanPhamEntity.KhuyenMaiText= _TblSanPhamEntity_XML.KhuyenMaiText;
				
			_TblSanPhamEntity.GiaBan= _TblSanPhamEntity_XML.GiaBan;
				
			_TblSanPhamEntity.GiaCu= _TblSanPhamEntity_XML.GiaCu;
				
			_TblSanPhamEntity.ThoiGianBaoHanh= _TblSanPhamEntity_XML.ThoiGianBaoHanh;
				
			_TblSanPhamEntity.DonViBaoHanh= _TblSanPhamEntity_XML.DonViBaoHanh;
				
			_TblSanPhamEntity.MetaKeyword= _TblSanPhamEntity_XML.MetaKeyword;
				
			_TblSanPhamEntity.MetaDesc= _TblSanPhamEntity_XML.MetaDesc;
				
			_TblSanPhamEntity.Tongquan= _TblSanPhamEntity_XML.Tongquan;
				
			_TblSanPhamEntity.Tinhnang= _TblSanPhamEntity_XML.Tinhnang;
				
			_TblSanPhamEntity.Baogom= _TblSanPhamEntity_XML.Baogom;
				
			_TblSanPhamEntity.Hinhthuc= _TblSanPhamEntity_XML.Hinhthuc;
				
			_TblSanPhamEntity.Baohanh= _TblSanPhamEntity_XML.Baohanh;
				
			_TblSanPhamEntity.Count= _TblSanPhamEntity_XML.Count;
				
			_TblSanPhamEntity.SoLuong= _TblSanPhamEntity_XML.SoLuong;
				
			_TblSanPhamEntity.ThuTu= _TblSanPhamEntity_XML.ThuTu;
				
			_TblSanPhamEntity.ChkQuantity= _TblSanPhamEntity_XML.ChkQuantity;
				
			_TblSanPhamEntity.TxtQuantity= _TblSanPhamEntity_XML.TxtQuantity;
				
			_TblSanPhamEntity.DonViTinhId= _TblSanPhamEntity_XML.DonViTinhId;
				
			_TblSanPhamEntity.Spmoi= _TblSanPhamEntity_XML.Spmoi;
				
			_TblSanPhamEntity.SpnoiBat= _TblSanPhamEntity_XML.SpnoiBat;
				
			_TblSanPhamEntity.SpHot= _TblSanPhamEntity_XML.SpHot;
				
			_TblSanPhamEntity.NgayDang= _TblSanPhamEntity_XML.NgayDang;
				
			_TblSanPhamEntity.TrangThai= _TblSanPhamEntity_XML.TrangThai;
				
			
			return _TblSanPhamEntity;
		}	
		
			
		public void InsertCollection(EntityCollection _Collection)
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
            {
                adapter.SaveEntityCollection(_Collection);
            }
		}

		public TblSanPhamEntity Insert(TblSanPhamEntity TblSanPhamEntity)
		{
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.SaveEntity(TblSanPhamEntity, true);
			}
			return TblSanPhamEntity;
		}

		
		public TblSanPhamEntity Insert(int Id, string Barcode, int DanhMucSpid, string TenDanhMuc, string TenSanPham, string TomTatHome, string TomTat, string Mota, string NhaCcid, string MaTienTe, string Image, string KhuyenMaiText, double GiaBan, double GiaCu, int ThoiGianBaoHanh, string DonViBaoHanh, string MetaKeyword, string MetaDesc, string Tongquan, string Tinhnang, string Baogom, string Hinhthuc, string Baohanh, int Count, double SoLuong, int ThuTu, int ChkQuantity, string TxtQuantity, int DonViTinhId, bool Spmoi, bool SpnoiBat, bool SpHot, DateTime NgayDang, bool TrangThai)
		{
			TblSanPhamEntity _TblSanPhamEntity = new TblSanPhamEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_TblSanPhamEntity.Id = Id;
				_TblSanPhamEntity.Barcode = Barcode;
				_TblSanPhamEntity.DanhMucSpid = DanhMucSpid;
				_TblSanPhamEntity.TenDanhMuc = TenDanhMuc;
				_TblSanPhamEntity.TenSanPham = TenSanPham;
				_TblSanPhamEntity.TomTatHome = TomTatHome;
				_TblSanPhamEntity.TomTat = TomTat;
				_TblSanPhamEntity.Mota = Mota;
				_TblSanPhamEntity.NhaCcid = NhaCcid;
				_TblSanPhamEntity.MaTienTe = MaTienTe;
				_TblSanPhamEntity.Image = Image;
				_TblSanPhamEntity.KhuyenMaiText = KhuyenMaiText;
				_TblSanPhamEntity.GiaBan = GiaBan;
				_TblSanPhamEntity.GiaCu = GiaCu;
				_TblSanPhamEntity.ThoiGianBaoHanh = ThoiGianBaoHanh;
				_TblSanPhamEntity.DonViBaoHanh = DonViBaoHanh;
				_TblSanPhamEntity.MetaKeyword = MetaKeyword;
				_TblSanPhamEntity.MetaDesc = MetaDesc;
				_TblSanPhamEntity.Tongquan = Tongquan;
				_TblSanPhamEntity.Tinhnang = Tinhnang;
				_TblSanPhamEntity.Baogom = Baogom;
				_TblSanPhamEntity.Hinhthuc = Hinhthuc;
				_TblSanPhamEntity.Baohanh = Baohanh;
				_TblSanPhamEntity.Count = Count;
				_TblSanPhamEntity.SoLuong = SoLuong;
				_TblSanPhamEntity.ThuTu = ThuTu;
				_TblSanPhamEntity.ChkQuantity = ChkQuantity;
				_TblSanPhamEntity.TxtQuantity = TxtQuantity;
				_TblSanPhamEntity.DonViTinhId = DonViTinhId;
				_TblSanPhamEntity.Spmoi = Spmoi;
				_TblSanPhamEntity.SpnoiBat = SpnoiBat;
				_TblSanPhamEntity.SpHot = SpHot;
				_TblSanPhamEntity.NgayDang = NgayDang;
				_TblSanPhamEntity.TrangThai = TrangThai;
				adapter.SaveEntity(_TblSanPhamEntity, true);
			}
			return _TblSanPhamEntity;
		}

		public TblSanPhamEntity Insert(string Barcode, int DanhMucSpid, string TenDanhMuc, string TenSanPham, string TomTatHome, string TomTat, string Mota, string NhaCcid, string MaTienTe, string Image, string KhuyenMaiText, double GiaBan, double GiaCu, int ThoiGianBaoHanh, string DonViBaoHanh, string MetaKeyword, string MetaDesc, string Tongquan, string Tinhnang, string Baogom, string Hinhthuc, string Baohanh, int Count, double SoLuong, int ThuTu, int ChkQuantity, string TxtQuantity, int DonViTinhId, bool Spmoi, bool SpnoiBat, bool SpHot, DateTime NgayDang, bool TrangThai)
		{
			TblSanPhamEntity _TblSanPhamEntity = new TblSanPhamEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_TblSanPhamEntity.Barcode = Barcode;
				_TblSanPhamEntity.DanhMucSpid = DanhMucSpid;
				_TblSanPhamEntity.TenDanhMuc = TenDanhMuc;
				_TblSanPhamEntity.TenSanPham = TenSanPham;
				_TblSanPhamEntity.TomTatHome = TomTatHome;
				_TblSanPhamEntity.TomTat = TomTat;
				_TblSanPhamEntity.Mota = Mota;
				_TblSanPhamEntity.NhaCcid = NhaCcid;
				_TblSanPhamEntity.MaTienTe = MaTienTe;
				_TblSanPhamEntity.Image = Image;
				_TblSanPhamEntity.KhuyenMaiText = KhuyenMaiText;
				_TblSanPhamEntity.GiaBan = GiaBan;
				_TblSanPhamEntity.GiaCu = GiaCu;
				_TblSanPhamEntity.ThoiGianBaoHanh = ThoiGianBaoHanh;
				_TblSanPhamEntity.DonViBaoHanh = DonViBaoHanh;
				_TblSanPhamEntity.MetaKeyword = MetaKeyword;
				_TblSanPhamEntity.MetaDesc = MetaDesc;
				_TblSanPhamEntity.Tongquan = Tongquan;
				_TblSanPhamEntity.Tinhnang = Tinhnang;
				_TblSanPhamEntity.Baogom = Baogom;
				_TblSanPhamEntity.Hinhthuc = Hinhthuc;
				_TblSanPhamEntity.Baohanh = Baohanh;
				_TblSanPhamEntity.Count = Count;
				_TblSanPhamEntity.SoLuong = SoLuong;
				_TblSanPhamEntity.ThuTu = ThuTu;
				_TblSanPhamEntity.ChkQuantity = ChkQuantity;
				_TblSanPhamEntity.TxtQuantity = TxtQuantity;
				_TblSanPhamEntity.DonViTinhId = DonViTinhId;
				_TblSanPhamEntity.Spmoi = Spmoi;
				_TblSanPhamEntity.SpnoiBat = SpnoiBat;
				_TblSanPhamEntity.SpHot = SpHot;
				_TblSanPhamEntity.NgayDang = NgayDang;
				_TblSanPhamEntity.TrangThai = TrangThai;
				adapter.SaveEntity(_TblSanPhamEntity, true);
			}
			return _TblSanPhamEntity;
		}

		public bool Update(TblSanPhamEntity _TblSanPhamEntity)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				RelationPredicateBucket filter = new RelationPredicateBucket();
				IPredicateExpression _PredicateExpression = new PredicateExpression();
				_PredicateExpression.Add(TblSanPhamFields.Id == _TblSanPhamEntity.Id);
					
				filter.PredicateExpression.Add(_PredicateExpression);

				adapter.UpdateEntitiesDirectly(_TblSanPhamEntity, filter);
				toReturn = true;
			}
			return toReturn;
		}
		
		public bool Update(TblSanPhamEntity _TblSanPhamEntity, RelationPredicateBucket filter)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.UpdateEntitiesDirectly(_TblSanPhamEntity, filter);
				toReturn = true;
			}
			return toReturn;
		}

		public bool Update(int Id, string Barcode, int DanhMucSpid, string TenDanhMuc, string TenSanPham, string TomTatHome, string TomTat, string Mota, string NhaCcid, string MaTienTe, string Image, string KhuyenMaiText, double GiaBan, double GiaCu, int ThoiGianBaoHanh, string DonViBaoHanh, string MetaKeyword, string MetaDesc, string Tongquan, string Tinhnang, string Baogom, string Hinhthuc, string Baohanh, int Count, double SoLuong, int ThuTu, int ChkQuantity, string TxtQuantity, int DonViTinhId, bool Spmoi, bool SpnoiBat, bool SpHot, DateTime NgayDang, bool TrangThai)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblSanPhamEntity _TblSanPhamEntity = new TblSanPhamEntity(Id);
				if (adapter.FetchEntity(_TblSanPhamEntity))
				{
				
					_TblSanPhamEntity.Barcode = Barcode;
					_TblSanPhamEntity.DanhMucSpid = DanhMucSpid;
					_TblSanPhamEntity.TenDanhMuc = TenDanhMuc;
					_TblSanPhamEntity.TenSanPham = TenSanPham;
					_TblSanPhamEntity.TomTatHome = TomTatHome;
					_TblSanPhamEntity.TomTat = TomTat;
					_TblSanPhamEntity.Mota = Mota;
					_TblSanPhamEntity.NhaCcid = NhaCcid;
					_TblSanPhamEntity.MaTienTe = MaTienTe;
					_TblSanPhamEntity.Image = Image;
					_TblSanPhamEntity.KhuyenMaiText = KhuyenMaiText;
					_TblSanPhamEntity.GiaBan = GiaBan;
					_TblSanPhamEntity.GiaCu = GiaCu;
					_TblSanPhamEntity.ThoiGianBaoHanh = ThoiGianBaoHanh;
					_TblSanPhamEntity.DonViBaoHanh = DonViBaoHanh;
					_TblSanPhamEntity.MetaKeyword = MetaKeyword;
					_TblSanPhamEntity.MetaDesc = MetaDesc;
					_TblSanPhamEntity.Tongquan = Tongquan;
					_TblSanPhamEntity.Tinhnang = Tinhnang;
					_TblSanPhamEntity.Baogom = Baogom;
					_TblSanPhamEntity.Hinhthuc = Hinhthuc;
					_TblSanPhamEntity.Baohanh = Baohanh;
					_TblSanPhamEntity.Count = Count;
					_TblSanPhamEntity.SoLuong = SoLuong;
					_TblSanPhamEntity.ThuTu = ThuTu;
					_TblSanPhamEntity.ChkQuantity = ChkQuantity;
					_TblSanPhamEntity.TxtQuantity = TxtQuantity;
					_TblSanPhamEntity.DonViTinhId = DonViTinhId;
					_TblSanPhamEntity.Spmoi = Spmoi;
					_TblSanPhamEntity.SpnoiBat = SpnoiBat;
					_TblSanPhamEntity.SpHot = SpHot;
					_TblSanPhamEntity.NgayDang = NgayDang;
					_TblSanPhamEntity.TrangThai = TrangThai;
					adapter.SaveEntity(_TblSanPhamEntity, true);
					toReturn = true;
				}
			}
			return toReturn;
		}

		public bool Delete(int Id)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblSanPhamEntity _TblSanPhamEntity = new TblSanPhamEntity(Id);
				if (adapter.FetchEntity(_TblSanPhamEntity))
				{
					adapter.DeleteEntity(_TblSanPhamEntity);
					toReturn = true;
				}
			}
			return toReturn;
		}
		
		public void DeleteAll() 
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.DeleteEntitiesDirectly("TblSanPhamEntity", null);
			}
		}
		
		
		public int DeleteById(int Id)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByBarcode(string Barcode)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Barcode == Barcode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDanhMucSpid(int DanhMucSpid)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.DanhMucSpid == DanhMucSpid);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTenDanhMuc(string TenDanhMuc)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TenDanhMuc == TenDanhMuc);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTenSanPham(string TenSanPham)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TenSanPham == TenSanPham);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTomTatHome(string TomTatHome)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TomTatHome == TomTatHome);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTomTat(string TomTat)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TomTat == TomTat);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByMota(string Mota)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Mota == Mota);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByNhaCcid(string NhaCcid)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.NhaCcid == NhaCcid);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByMaTienTe(string MaTienTe)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.MaTienTe == MaTienTe);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByImage(string Image)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Image == Image);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByKhuyenMaiText(string KhuyenMaiText)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.KhuyenMaiText == KhuyenMaiText);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByGiaBan(double GiaBan)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.GiaBan == GiaBan);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByGiaCu(double GiaCu)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.GiaCu == GiaCu);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByThoiGianBaoHanh(int ThoiGianBaoHanh)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.ThoiGianBaoHanh == ThoiGianBaoHanh);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDonViBaoHanh(string DonViBaoHanh)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.DonViBaoHanh == DonViBaoHanh);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByMetaKeyword(string MetaKeyword)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.MetaKeyword == MetaKeyword);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByMetaDesc(string MetaDesc)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.MetaDesc == MetaDesc);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTongquan(string Tongquan)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Tongquan == Tongquan);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTinhnang(string Tinhnang)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Tinhnang == Tinhnang);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByBaogom(string Baogom)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Baogom == Baogom);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByHinhthuc(string Hinhthuc)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Hinhthuc == Hinhthuc);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByBaohanh(string Baohanh)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Baohanh == Baohanh);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByCount(int Count)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Count == Count);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteBySoLuong(double SoLuong)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.SoLuong == SoLuong);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByThuTu(int ThuTu)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.ThuTu == ThuTu);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByChkQuantity(int ChkQuantity)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.ChkQuantity == ChkQuantity);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTxtQuantity(string TxtQuantity)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TxtQuantity == TxtQuantity);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDonViTinhId(int DonViTinhId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.DonViTinhId == DonViTinhId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteBySpmoi(bool Spmoi)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Spmoi == Spmoi);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteBySpnoiBat(bool SpnoiBat)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.SpnoiBat == SpnoiBat);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteBySpHot(bool SpHot)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.SpHot == SpHot);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByNgayDang(DateTime NgayDang)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.NgayDang == NgayDang);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTrangThai(bool TrangThai)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblSanPhamEntity", filter);
			}
			return toReturn;
		}
		

		
		public TblSanPhamEntity SelectOne(int Id)
		{
			TblSanPhamEntity toReturn = null;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblSanPhamEntity _TblSanPhamEntity = new TblSanPhamEntity(Id);
				if (adapter.FetchEntity(_TblSanPhamEntity))
				{
					toReturn = _TblSanPhamEntity;
				}
			}
			return toReturn;
		}

		// Return EntityCollection
		public EntityCollection SelectAll()
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection( new TblSanPhamEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, null, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectAllRDT()
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, null, true);
			}
			return toReturn;
		}

		
		// Return EntityCollection
		public EntityCollection SelectById(int Id)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT(int Id)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByBarcode(string Barcode)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Barcode == Barcode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByBarcodeRDT(string Barcode)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Barcode == Barcode);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByDanhMucSpid(int DanhMucSpid)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.DanhMucSpid == DanhMucSpid);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDanhMucSpidRDT(int DanhMucSpid)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.DanhMucSpid == DanhMucSpid);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTenDanhMuc(string TenDanhMuc)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TenDanhMuc == TenDanhMuc);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTenDanhMucRDT(string TenDanhMuc)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TenDanhMuc == TenDanhMuc);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTenSanPham(string TenSanPham)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TenSanPham == TenSanPham);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTenSanPhamRDT(string TenSanPham)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TenSanPham == TenSanPham);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTomTatHome(string TomTatHome)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TomTatHome == TomTatHome);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTomTatHomeRDT(string TomTatHome)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TomTatHome == TomTatHome);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTomTat(string TomTat)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TomTat == TomTat);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTomTatRDT(string TomTat)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TomTat == TomTat);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByMota(string Mota)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Mota == Mota);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByMotaRDT(string Mota)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Mota == Mota);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByNhaCcid(string NhaCcid)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.NhaCcid == NhaCcid);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByNhaCcidRDT(string NhaCcid)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.NhaCcid == NhaCcid);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByMaTienTe(string MaTienTe)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.MaTienTe == MaTienTe);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByMaTienTeRDT(string MaTienTe)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.MaTienTe == MaTienTe);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByImage(string Image)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Image == Image);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByImageRDT(string Image)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Image == Image);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByKhuyenMaiText(string KhuyenMaiText)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.KhuyenMaiText == KhuyenMaiText);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByKhuyenMaiTextRDT(string KhuyenMaiText)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.KhuyenMaiText == KhuyenMaiText);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByGiaBan(double GiaBan)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.GiaBan == GiaBan);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByGiaBanRDT(double GiaBan)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.GiaBan == GiaBan);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByGiaCu(double GiaCu)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.GiaCu == GiaCu);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByGiaCuRDT(double GiaCu)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.GiaCu == GiaCu);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByThoiGianBaoHanh(int ThoiGianBaoHanh)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.ThoiGianBaoHanh == ThoiGianBaoHanh);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByThoiGianBaoHanhRDT(int ThoiGianBaoHanh)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.ThoiGianBaoHanh == ThoiGianBaoHanh);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByDonViBaoHanh(string DonViBaoHanh)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.DonViBaoHanh == DonViBaoHanh);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDonViBaoHanhRDT(string DonViBaoHanh)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.DonViBaoHanh == DonViBaoHanh);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByMetaKeyword(string MetaKeyword)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.MetaKeyword == MetaKeyword);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByMetaKeywordRDT(string MetaKeyword)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.MetaKeyword == MetaKeyword);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByMetaDesc(string MetaDesc)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.MetaDesc == MetaDesc);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByMetaDescRDT(string MetaDesc)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.MetaDesc == MetaDesc);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTongquan(string Tongquan)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Tongquan == Tongquan);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTongquanRDT(string Tongquan)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Tongquan == Tongquan);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTinhnang(string Tinhnang)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Tinhnang == Tinhnang);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTinhnangRDT(string Tinhnang)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Tinhnang == Tinhnang);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByBaogom(string Baogom)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Baogom == Baogom);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByBaogomRDT(string Baogom)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Baogom == Baogom);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByHinhthuc(string Hinhthuc)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Hinhthuc == Hinhthuc);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByHinhthucRDT(string Hinhthuc)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Hinhthuc == Hinhthuc);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByBaohanh(string Baohanh)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Baohanh == Baohanh);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByBaohanhRDT(string Baohanh)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Baohanh == Baohanh);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByCount(int Count)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Count == Count);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByCountRDT(int Count)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Count == Count);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectBySoLuong(double SoLuong)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.SoLuong == SoLuong);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectBySoLuongRDT(double SoLuong)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.SoLuong == SoLuong);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByThuTu(int ThuTu)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.ThuTu == ThuTu);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByThuTuRDT(int ThuTu)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.ThuTu == ThuTu);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByChkQuantity(int ChkQuantity)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.ChkQuantity == ChkQuantity);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByChkQuantityRDT(int ChkQuantity)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.ChkQuantity == ChkQuantity);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTxtQuantity(string TxtQuantity)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TxtQuantity == TxtQuantity);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTxtQuantityRDT(string TxtQuantity)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TxtQuantity == TxtQuantity);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByDonViTinhId(int DonViTinhId)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.DonViTinhId == DonViTinhId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDonViTinhIdRDT(int DonViTinhId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.DonViTinhId == DonViTinhId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectBySpmoi(bool Spmoi)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Spmoi == Spmoi);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectBySpmoiRDT(bool Spmoi)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.Spmoi == Spmoi);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectBySpnoiBat(bool SpnoiBat)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.SpnoiBat == SpnoiBat);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectBySpnoiBatRDT(bool SpnoiBat)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.SpnoiBat == SpnoiBat);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectBySpHot(bool SpHot)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.SpHot == SpHot);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectBySpHotRDT(bool SpHot)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.SpHot == SpHot);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByNgayDang(DateTime NgayDang)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.NgayDang == NgayDang);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByNgayDangRDT(DateTime NgayDang)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.NgayDang == NgayDang);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTrangThai(bool TrangThai)
		{
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblSanPhamCollection, filter, 0, null);
			}
			return _TblSanPhamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTrangThaiRDT(bool TrangThai)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblSanPhamCollection = new EntityCollection(new TblSanPhamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblSanPhamFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblSanPhamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		

	}
}
